#include <bits/stdc++.h>
using namespace std;
using ll = long long;

string s;
vector<vector<int>> memo(5010, vector<int>(5010, -1));
int dfs(int l, int r)
{
  if (memo[l][r] != -1)
    return memo[l][r];
  if (l >= r)
    return 0;
  if (s[l] < s[r])
    return memo[l][r] = 0;
  if (s[l] > s[r])
    return memo[l][r] = 1;
  // 看子区间的两端点
  return memo[l][r] = dfs(l + 1, r - 1);
}

int main()
{
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> s;
  int n = s.length();
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++)
      ans += dfs(i, j);
  cout << ans;
  return 0;
}